<?php

namespace App\Http\Services;

use Illuminate\Support\Facades\DB;
use App\Http\Model\Hint;
use App\Http\Model\User;
use App\Http\Model\ShortcutWord;

class ShortcutWordServices extends CommonServices
{
    protected $userModel;
    protected $shortcutWordModel;

    public function __construct()
    {
        parent::__construct();

        $this->user = new User();
        $this->shortcutWordModel = new ShortcutWord();

    }

    /**
     * 添加快捷语
     */
    public function addShortcutWord($params=[]){
        $code = Hint::SUCCESS;
        $msg = '';
        $data = [];
        do {
            $id = $this->shortcutWordModel->createShortcutWord($params);

        } while (false);

        return compact('code', 'msg', 'data');
    }

    /**
     * 编辑快捷语
     */
    public function editShortcutWord($id, $params=[]){
        $code = Hint::SUCCESS;
        $msg = '';
        $data = [];
        do {
            if(empty($id) || empty($params)) {
                break;
            }
            $res = $this->shortcutWordModel->updateShortcutWord($id, $params);

        } while (false);

        return compact('code', 'msg', 'data');
    }

    /**
     * 删除快捷语
     */
    public function delShortcutWord($id, $params=[]){
        $code = Hint::SUCCESS;
        $msg = '';
        $data = [];
        do {
            if(empty($id) || empty($params)) {
                break;
            }
            $params['is_delete'] = 1;
            $res = $this->shortcutWordModel->updateShortcutWord($id, $params);

        } while (false);

        return compact('code', 'msg', 'data');
    }

    /**
     * 快捷语列表
     */
    public function shortcutWordList(){
        $code = Hint::SUCCESS;
        $msg = '';
        $data = [];
        do {
            $list = $this->shortcutWordModel->shortcutWordAll();

            $data = $list;

        } while (false);

        return compact('code', 'msg', 'data');
    }

}